package hadooprpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

public class MyNameNode implements BizProtocol {
    @Override
    public void mkdirDirects(String path) {
        System.out.println(path + "目录已经创建好");
    }

    @Override
    public void sayHello(String name) {
        System.out.println("hello " + name);
    }

    public static void main(String[] args) throws IOException {
        try {
            RPC.Server server = new RPC.Builder(new Configuration())
                    .setProtocol(BizProtocol.class)
                    .setInstance(new MyNameNode())
                    .setBindAddress("localhost")
                    .setPort(9999)
                    .build();

            server.start();// 这段代码就是一个死循环 一直会运行
            //等待别人去连接它
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
